<?php
/**
 * Created by PhpStorm.
 * User: s.utkin
 * Date: 17.10.14
 * Time: 20:47
 */

namespace Pinenut\Test;

use Pinenut\Di\Injectable;
use Pinenut\Model2;

class FixtureManager {

	public static $fixturesDir;

	public static function loadFixture($className) {
		$dataFileName = str_replace('\\', '/', $className) . '.php';
		$documents = require (static::$fixturesDir . DIRECTORY_SEPARATOR . $dataFileName);

		/** @var Model2 $model */
		$model = new $className();
		$adapter = $model->getAdapter();
		$adapter->remove();

		foreach ((array)$documents as $document) {
			$s = $adapter->insert($document);
		}
	}
} 